T = int(input())

def check(x):
    if x <= 0:
        return False
    s = str(x)
    for i in s:
        if i != s[0]:
            return False
    return True

def gener(x, len):
    return int(str(x) * len)

while T > 0:
    T -= 1
    s = input()
    lens = len(s)
    x = int(s)
    ok = 0
    for i in range(1, 10):
        if check(x - gener(i, lens)):
            ok = True
            t = gener(i, lens)
            print(t, x - t)
            break
    if ok :
        continue
    for i in range(1, 10):
        if check(x - gener(i, lens - 1)):
            ok = True
            t = gener(i, lens - 1)
            print(t, x - t)
            break
